package org.ruoyi.alibaba.chat.config;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;
import com.alibaba.cloud.ai.dashscope.embedding.DashScopeEmbeddingModel;
import com.alibaba.cloud.ai.dashscope.embedding.DashScopeEmbeddingOptions;
import org.springframework.ai.document.MetadataMode;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ModelConfig {

    @Bean
    public EmbeddingModel embeddingModel() {
        // Can be any other EmbeddingModel implementatio0n.

        System.out.println(System.getenv("DASHSCOPE_API_KEY")+"api");
        // 手动配置示例
        DashScopeApi dashscopeApiKey = new DashScopeApi(System.getenv("DASHSCOPE_API_KEY"));

        return new DashScopeEmbeddingModel(dashscopeApiKey, MetadataMode.EMBED, DashScopeEmbeddingOptions.builder().withModel("text-embedding-v3").build());
    }
}
